namespace Ultima {
  public class HuedTileList {
    private int m_Count;
    private HuedTile[] m_Tiles;

    public HuedTileList() {
      this.m_Tiles = new HuedTile[8];
      this.m_Count = 0;
    }

    public int Count {
      get { return this.m_Count; }
    }

    public void Add( short id, short hue, sbyte z ) {
      if ( ( this.m_Count + 1 ) > this.m_Tiles.Length ) {
        HuedTile[] old = this.m_Tiles;
        this.m_Tiles = new HuedTile[old.Length * 2];

        for ( int i = 0; i < old.Length; ++i )
          this.m_Tiles[i] = old[i];
      }

      this.m_Tiles[this.m_Count++].Set( id, hue, z );
    }

    public HuedTile[] ToArray() {
      var tiles = new HuedTile[this.m_Count];

      for ( int i = 0; i < this.m_Count; ++i )
        tiles[i] = this.m_Tiles[i];

      this.m_Count = 0;

      return tiles;
    }
  }


  public class TileList {
    private int m_Count;
    private Tile[] m_Tiles;

    public TileList() {
      this.m_Tiles = new Tile[8];
      this.m_Count = 0;
    }

    public int Count {
      get { return this.m_Count; }
    }

    public void Add( short id, sbyte z ) {
      if ( ( this.m_Count + 1 ) > this.m_Tiles.Length ) {
        Tile[] old = this.m_Tiles;
        this.m_Tiles = new Tile[old.Length * 2];

        for ( int i = 0; i < old.Length; ++i )
          this.m_Tiles[i] = old[i];
      }

      this.m_Tiles[this.m_Count++].Set( id, z );
    }

    public Tile[] ToArray() {
      var tiles = new Tile[this.m_Count];

      for ( int i = 0; i < this.m_Count; ++i )
        tiles[i] = this.m_Tiles[i];

      this.m_Count = 0;

      return tiles;
    }
  }
}